package org.zqy.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.zqy.dao.UserDao;
import org.zqy.domain.User;

/** 实现用户接口接口 */
public class UserDaoImpl extends BaseDaoImpl implements UserDao {

	@Override
	public boolean addUser(User user) {
		return CommonOpt(user, BaseDaoImpl.SAVE);
	}

	@Override
	public boolean deleteUser(User user) {
		return CommonOpt(user, BaseDaoImpl.DELETE);
	}

	@Override
	public boolean updateUser(User user) {
		return CommonOpt(user, BaseDaoImpl.UPDATE);
	}

	@SuppressWarnings("unchecked")
	@Override
	public ArrayList<User> getUsers() {
		return (ArrayList<User>) queryByHql("from User");
	}

	@Override
	public User getUser(String uaccount) {
		System.out.println(uaccount);
		@SuppressWarnings("unchecked")
		List<User> list = queryByHql("from User where uaccount='" + uaccount
				+ "'");
		if (list != null) {
			return list.get(0);
		}
		return null;
	}

}
